<%@page import="java.sql.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>查询数据</title>
</head>
<body>
	<h2>显示所有信息</h2>
	<table>
		<tr>
			<td>用户名</td>
			<td>密码</td>
		</tr>

		<%
			String driver = "com.mysql.cj.jdbc.Driver";
			String url = "jdbc:mysql://localhost:3306/test?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai";
			Class.forName(driver);
			Connection conn = DriverManager.getConnection(url, "root", "Zxl5201314,");
			Statement stmt = conn.createStatement();
			String sql = "select * from user";
			ResultSet rs = stmt.executeQuery(sql);
			while (rs.next()) {
		%>
		<tr>
			<td><%=rs.getString("username")%></td>
			<td><%=rs.getString("password")%></td>
		</tr>
		<%
			}
			stmt.close();
			conn.close();
		%>

	</table>

</body>
</html>